import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/Table';
import {RenderType} from '@pkg/setting';
import { companyList } from './api';
export const columns: BasicColumn[] = [
  {
    title: '所属机构',
    dataIndex: 'companyName',
    width: 150,
  },
  {
    title: '设备名称',
    dataIndex: 'deviceName',
    width: 150,
  },
  {
    title: '设备编号',
    dataIndex: 'deviceNo',
    width: 150,
  },
  {
    title: '授权状态',
    dataIndex: 'state',
    width: 80,
    dictData: [
      { label: '启用', value: 1, color: 'green' },
      { label: '禁用', value: 0, color: 'red' }
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 150,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    label: '所属机构',
    field: 'companyId',
    component: 'ApiSelect',
    componentProps: {
      api: companyList,
      showSearch:true,
      immediate: true,
      labelField: 'companyName',
      valueField: 'companyId',
    },
  },
  {
    field: 'deviceNo',
    label: '设备编号',
    component: 'Input',
    colProps: { span: 4 },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '所属机构',
    field: 'companyId',
    component: 'ApiSelect',
    required: true,
    componentProps: {
      api: companyList,
      showSearch:true,
      labelField: 'companyName',
      valueField: 'companyId',
    },
  },
  {
    label: '设备名称',
    field: 'deviceName',
    component: 'Input',
    required: true,
  },
  {
    label: '设备编号',
    field: 'deviceNo',
    component: 'Input',
    required: true,
  },
  {
    field: 'state',
    label: '授权状态',
    component: 'ApiRadioGroup',
    componentProps: {
      options: [
        { label: '启用', value: 1, color: '#a6a9a6' },
        { label: '禁用', value: 0, color: '#09d550' }
      ],
    },
  },
];
